package borge.web.teamspirit.client.data;

import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import borge.web.teamspirit.client.interfaces.PersistentData;
import borge.web.teamspirit.client.servercomm.DBQuery;

/**
 * Database object.
 * An event tells us that something has happened on the site
 * For example, new match, new serie, new comment, results and so on.
 * A user can click on the event and the app should load a page
 * to present the event (the match page, news, stats or so on)
 * @author Andreas Borglin
 *
 */

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class Event implements PersistentData {

	//private static final long serialVersionUID = 7618348100954634699L;

	/* Encoded key generated by GAE when first saved.
	 * Guaranteed to be unique and contains mapping to 
	 * a team using gae.pk-name key defined below. */
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    private String iEncodedKey;
    
	// Parent can be any entity
    @Persistent
    private String iParentKey;
    
    @Persistent
    private Date iDate;
    
    @Persistent
    private String iPersonName;
    
    @Persistent
    private String iText;
    
    @Persistent
    private String iToken;
    
	public Event(){
	    
	}
	
	public void setParentKey(String aKey){
		iParentKey = aKey;
	}
	
	public String getParentKey(){
		return iParentKey;
	}
	
	public void setPersonName(String aName){
		iPersonName = aName;
	}
	
	public String getPersonName(){
		return iPersonName;
	}
	
	public void setToken(String aToken){
		iToken = aToken;
	}
	
	public String getToken(){
		return iToken;
	}
	
	public void setDate(Date aDate){
		iDate = aDate;
	}
	
	public Date getDate(){
		return iDate;
	}
	
	public void setText(String aText){
		iText = aText;
	}
	
	public String getText(){
		return iText;
	}
	
	
	public String dumpContent(){
	    return new String("Dump" +
	            "\nId:" + iEncodedKey +
	            "\nDate:" + iDate + 
	            "\nPlayer:" + iPersonName +
	            "\nText:" + iText);
	}

	@Override
	public String getDisplayingWidget() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getEncodedKey() {
		// TODO Auto-generated method stub
		return null;
	}
	
}
